Talk:Treasure Chest/@comment-66.191.216.12-20140619203709/@comment-24475768-20141017151357
I know, right? This second method is sooo slow ^^ It's the method used by the Windmill quest in Crossroads, I've always hated waiting for him to give me the 10 coins. Maybe you could mix the two methods, giving multiple coins each time, 3 or 4 times, instead of everything one by one. For the first method, you forgot to put the each of line as a child of WHEN once. As a result, you create 10 coins... at each frame for as long as your chest is not destroyed! I have not talked about another possiblity, which involves creating only one coin, but which gives you a total of 10 coins when you pick it up. This is probably what you want. However, you don't need to change the Treasure Chest brain except for one thing: don't create a coin with the gallery picker tile, use rather a coin template (that you select with the in-world picker). It is its default brain, "Pickup - Coin", which you need to modify. Remove the second page, and the switch page to that page (line 8), instead put destroy (or destroy me, but by default destroy uses me). Also get rid of the line player up me, as you actually destroy the coin. Then, since you want to be able to get 10 coins (for example) at a time, change the "1" in line 5 to "10", or whatever you want to obtain when you get the coin. This works since the player 'account' is really the "coin counter" number variable. When you want to buy an item, you also do operations on this variable (decrementing it by the price of the item). If you use a coin template, you can do a pretty neat thing, which is to choose how much a coin is worth without actually using one template for each value you want your coin to have. To do that, don't increment the player "coin counter" by a specific value like 10, but by a number variable called "coin value". Now, you want to set the "coin value" of the coin right after you create it (or it would increment the player's "coin counter" by the value a number variable has until you set it for the first time, that is to say 0). Instead of just having "WHEN DO create picker -> coin template etc.", you need to store the coin you create in an object variable "coin" so that you can set its "coin value" variable, so: WHEN DO var: coin equals create picker -> coin template etc. WHEN DO var: coin var: coin value equals 10 Using this more sophisticated method, you can precise what a coin is worth whenever you create one. As a final note, you may not want to have to set the coin value over and over again if you often use the value 1, which would be a normal default value. In that case, don't put the "coin value" line, its value will stay at 0. Since you know it is 0, but would rather want a default of 1, add at the beginning of your template brain: WHEN once DO > WHEN var: coin value to 0 DO var: coin value equals 1 So if you haven't changed its value, it will automatically be set to 1 thanks to that kode. If you do set its value right after you create it, it won't meet the "var: coin value to 0" condition, so you'll be fine.